<?php
class News extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->model('news_model');
        $this->load->helper('url_helper');
        $this->load->helper('url');
        $this->load->helper('file');
        $this->load->model('users_model');
        $this->load->library('session');
    }

    public function index()//分页显示
    {
        $rows = $this->input->post('rows');
        $page = $this->input->post('page');

        $data['rows'] = $this->news_model->get_news($rows,$page);
        $data['total'] = $this->news_model->total_news();
        echo json_encode($data);
    }
    //文章管理
    public function blogManage()
    {
        $this->load->view('pages/blogManage');
    }
    public function  modifyBlog($id){//还不能加载更改的内容
        //echo $id;
        $data['id']=$id;
        $this->load->view('pages/modify135',$data);
    }
    public function write135(){//还不能加载更改的内容
       // $id = $this->input->post('emotion');
      //  echo $id;
        $data['arr'] = $this->news_model->ims_punch_cat(1);
        $data['arr1'] = $this->news_model->ims_punch_cat(2);
       // echo json_encode($data);
        $this->load->view('pages/upload',$data);

    }
    public  function find(){//查找
        $id = $this->input->post('id');
        $arr = $this->news_model->get_new($id);
        $data = array();
        foreach($arr[0] as $key=>$value) {
            $data[$key] = $value;
        }
        echo json_encode($data);
    }
    public function save(){

    }
    public function  delete(){
        $id0 = $this->input->post('ids');
        $id = explode(",",$id0);
        foreach($id as $data) {
            $this->news_model->delete_new($data);
        }
        $this->output
            ->set_content_type('application/json')
            ->set_output(json_encode(array('success' => 'true')));
        return null;
        $this->load->view('pages/blogManage');
    }
}
